<HTML>
<HEAD>
<TITLE>
Informacion.cpp
</TITLE>
</HEAD>
<BODY>
<PRE>
<font color="blue">#include</font> <font color="maroon">"Informacion.h"</font>

Informacion<font color="black">:</font><font color="black">:</font>Informacion<font color="black">(</font><font color="blue">int</font> tamanioClave, <font color="blue">int</font> tamanioId<font color="black">)</font>
<font color="black">{</font>
    <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>tamanioClave<font color="black">=</font>tamanioClave;
    <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>tamanioID<font color="black">=</font>tamanioId;
    info<font color="black">=</font>NULL;
<font color="black">}</font>


<font color="blue">void</font> Informacion<font color="black">:</font><font color="black">:</font>Cargar<font color="black">(</font>FILE <font color="black">*</font>fuente<font color="black">)</font>
<font color="black">{</font>
    <font color="blue">if</font><font color="black">(</font>info<font color="black">)</font>
        free<font color="black">(</font>info<font color="black">)</font>;
    info<font color="black">=</font> <font color="black">(</font><font color="blue">char</font><font color="black">*</font><font color="black">)</font> malloc<font color="black">(</font>tamanioClave<font color="black">+</font>tamanioID<font color="black">)</font>;
    fread <font color="black">(</font> info, <font color="maroon">1</font>, tamanioClave<font color="black">+</font>tamanioID, fuente <font color="black">)</font>;
<font color="black">}</font>



<font color="blue">int</font> Informacion<font color="black">:</font><font color="black">:</font>Comparar<font color="black">(</font>Clave <font color="black">*</font>DatoAComparar<font color="black">)</font>
<font color="black">{</font>
    <font color="blue">return</font> <font color="black">-</font>DatoAComparar<font color="black">-</font><font color="black">&#62;</font>Comparar<font color="black">(</font><font color="blue">this</font><font color="black">)</font>;
<font color="black">}</font>



<font color="blue">int</font> Informacion<font color="black">:</font><font color="black">:</font>Comparar<font color="black">(</font>Informacion <font color="black">*</font>datoAComparar<font color="black">)</font>
<font color="black">{</font>
    <font color="blue">return</font> memcmp<font color="black">(</font><font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>info, datoAComparar<font color="black">-</font><font color="black">&#62;</font>info, tamanioClave<font color="black">+</font>tamanioID<font color="black">)</font>;
<font color="black">}</font>



<font color="blue">char</font> <font color="black">*</font>Informacion<font color="black">:</font><font color="black">:</font>GetPrimaryKey<font color="black">(</font><font color="black">)</font>
<font color="black">{</font>
    <font color="blue">char</font><font color="black">*</font> aux<font color="black">=</font> <font color="black">(</font><font color="blue">char</font><font color="black">*</font><font color="black">)</font>malloc<font color="black">(</font>tamanioID<font color="black">)</font>;
    memset<font color="black">(</font>aux,<font color="maroon">0</font>,tamanioID<font color="black">)</font>;

    memcpy<font color="black">(</font>aux,<font color="black">(</font><font color="blue">char</font><font color="black">*</font><font color="black">)</font>info<font color="black">+</font>tamanioClave,tamanioID<font color="black">)</font>;

    <font color="blue">return</font> aux;
<font color="black">}</font>

<font color="blue">unsigned</font> <font color="blue">int</font> Informacion<font color="black">:</font><font color="black">:</font>GetID<font color="black">(</font><font color="black">)</font>
<font color="black">{</font>
    <font color="blue">unsigned</font> <font color="blue">int</font><font color="black">*</font> aux<font color="black">=</font> <font color="black">(</font><font color="blue">unsigned</font> <font color="blue">int</font><font color="black">*</font><font color="black">)</font>malloc<font color="black">(</font><font color="maroon">4</font><font color="black">)</font>;
    memset<font color="black">(</font>aux,<font color="maroon">0</font>,tamanioID<font color="black">)</font>;

    memcpy<font color="black">(</font>aux,<font color="black">(</font><font color="blue">char</font><font color="black">*</font><font color="black">)</font>info<font color="black">+</font>tamanioClave,tamanioID<font color="black">)</font>;

    <font color="blue">return</font> <font color="black">*</font>aux;
<font color="black">}</font>

Informacion<font color="black">:</font><font color="black">:</font>~Informacion<font color="black">(</font><font color="black">)</font>
<font color="black">{</font>
    <font color="blue">if</font><font color="black">(</font>info<font color="black">)</font>
        free<font color="black">(</font>info<font color="black">)</font>;
<font color="black">}</font>



<font color="blue">void</font> Informacion<font color="black">:</font><font color="black">:</font>Guardar<font color="black">(</font>FILE <font color="black">*</font>destino<font color="black">)</font>
<font color="black">{</font>
    fwrite <font color="black">(</font> info, <font color="maroon">1</font>, tamanioClave<font color="black">+</font>tamanioID, destino <font color="black">)</font>;
<font color="black">}</font>



<font color="blue">void</font> Informacion<font color="black">:</font><font color="black">:</font>Cargar<font color="black">(</font><font color="blue">char</font> <font color="black">*</font>info<font color="black">)</font>
<font color="black">{</font>
    <font color="blue">if</font><font color="black">(</font><font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>info<font color="black">)</font>
        free<font color="black">(</font><font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>info<font color="black">)</font>;
    <font color="blue">this</font><font color="black">-</font><font color="black">&#62;</font>info<font color="black">=</font>info;
<font color="black">}</font>



Clave <font color="black">*</font>Informacion<font color="black">:</font><font color="black">:</font>GetClave<font color="black">(</font><font color="black">)</font>
<font color="black">{</font>
    Clave <font color="black">*</font>clave<font color="black">=</font> <font color="blue">new</font> Clave<font color="black">(</font>tamanioClave<font color="black">)</font>;
    <font color="blue">char</font><font color="black">*</font> aux<font color="black">=</font> <font color="black">(</font><font color="blue">char</font><font color="black">*</font><font color="black">)</font> malloc<font color="black">(</font>tamanioClave<font color="black">)</font>;
    memcpy<font color="black">(</font>aux, info, tamanioClave<font color="black">)</font>;
    clave<font color="black">-</font><font color="black">&#62;</font>Cargar<font color="black">(</font>aux<font color="black">)</font>;
    <font color="blue">return</font> clave;
<font color="black">}</font>




</PRE>
</BODY>
</HTML>
